<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
	th:with="title='管理中心',active='article'">
<header
	th:replace="admin/admin_header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
	<div id="wrapper">
		<div th:replace="admin/admin_header::header-body"></div>
		<div class="content-page">
			<div class="content">
				<div class="container">
					<div class="row">
						<div class="col-sm-12">
							<h4 class="page-title">举报管理</h4>
						</div>
						<div class="col-md-12">
							<table class="table table-striped table-bordered">
								<thead>
									<tr>
										<th>举报内容</th>
										<th>举报人</th>
										<th>举报时间</th>
										<th>举报邮箱</th>
										<th>预览文章</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<th:block th:each="comment : ${comments.list}">
										<tr th:attr="cid=${comment.coid}">
											<td><a th:utext="${commons.article(comment.content)}"></a>
											</td>
											<td th:text="${comment.author}"></td>
											<td
												th:text="${commons.fmtdate(comment.created, 'yyyy-MM-dd HH:mm:ss')}"></td>
											<td th:text="${comment.mail}"></td>
											<td><a
												th:href="@{${commons.site_url('/article/')}+${comment.cid}+'#comments'}"
												target="_blank">文章内容</a></td>
											<!--                                     <td> -->
											<!--                                         <th:block th:if="${comment.status == 'approved'}"> -->
											<!--                                             <span class="label label-success">审核通过</span> -->
											<!--                                         </th:block> -->
											<!--                                         <th:block th:if="${comment.status == 'not_audit'}"> -->
											<!--                                             <span class="label label-default">未审核</span> -->
											<!--                                         </th:block> -->
											<!--                                     </td> -->
											<td>
												<!--                                         <th:block th:if="${comment.status == 'not_audit'}"> -->
												<!--                                             <a href="javascript:void(0)" -->
												<!--                                                th:onclick="'updateStatus('+${comment.coid}+', approved);'" -->
												<!--                                                class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i -->
												<!--                                                     class="fa fa-trash-o"></i> <span>通过</span></a> -->
												<!--                                         </th:block> -->
												<a href="javascript:void(0)"
												th:onclick="'delComment('+${comment.coid}+');'"
												class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
													class="fa fa-trash-o"></i> <span>删除举报</span></a> <a
												href="javascript:void(0)"
												th:onclick="'delArt('+${comment.coid}+','+${comment.cid}+');'"
												class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
													class="fa fa-trash-o"></i> <span>删除文章</span></a>
											</td>
										</tr>
									</th:block>
								</tbody>
							</table>
							<div th:replace="comm/macros :: pageAdminNav(${comments})"></div>
						</div>
					</div>
					<div th:replace="admin/footer :: footer-content"></div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="admin/footer :: footer"></div>
	<script type="text/javascript">
		/*<![CDATA[*/
		var tale = new $.tale();

		function delComment(coid) {
			tale.alertConfirm({
				title : '确定删除该举报吗?',
				then : function() {
					tale.post({
						url : '/admin/comments/delete',
						data : {
							coid : coid
						},
						success : function(result) {
							if (result && result.success) {
								tale.alertOkAndReload('举报删除成功');
							} else {
								tale.alertError(result.msg || '举报删除失败');
							}
						}
					});
				}
			});
		}

		function delArt(coid,cid) {
			tale.alertConfirm({
				title : '确定删除该文章吗?',
				then : function() {
					tale.post({
						url : '/admin/report/delete',
						data : {
							coid : coid,
							cid : cid
						},
						success : function(result) {
							if (result && result.success) {
								tale.alertOkAndReload('文章删除成功');
							} else {
								tale.alertError(result.msg || '文章删除失败');
							}
						}
					});
				}
			});
		}

		function updateStatus(coid, status) {
			tale.post({
				url : '/admin/comments/status',
				data : {
					coid : coid,
					status : status
				},
				success : function(result) {
					if (result && result.success) {
						tale.alertOkAndReload('评论状态设置成功');
					} else {
						tale.alertError(result.msg || '评论设置失败');
					}
				}
			});
		}
		/*]]>*/
	</script>
</body>
</html>